frameclock: Run paint idle from flush idle
authorBenjamin Otte <otte@redhat.com>
Sun, 10 Jul 2022 19:15:22 +0000 (21:15 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 10 Jul 2022 19:33:32 +0000 (21:33 +0200)
Don't return to the main loop, instead force a run of the paint idle.
The paint idle will know to skip all the phases that aren't requested.

This is critically important becuase gdksurface.c assumes the
FLUSH_EVENTS and RESUME_EVENTS phases are matched, and we cannot
guarantee that if we return to the main loop and let various reentrant
code change the frame clock state.

This would lead to bugs with events being paused and never unpaused
again or even crashes.

Fixes #4941

gdk/gdkframeclockidle.c

index 10c4e5cd2a09a3acfc4ad020ff37f7a57b2a64bb..9c0c7263ddcd81a85b72c8755eba05e677f14d7b 100644 (file)
@@ -373,6 +373,9 @@ gdk_frame_clock_flush_idle (void *data)
   else
     priv->phase = GDK_FRAME_CLOCK_PHASE_NONE;
 
+  g_clear_handle_id (&priv->paint_idle_id, g_source_remove);
+  gdk_frame_clock_paint_idle (data);
+
   return FALSE;
 }